﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ent;
namespace DAL
{
    public class ChiTietDeThiDAL:clsKetNoi
    {
        dataDataContext dt;
        public List<CauHoiThi> Laydanhsachcauhoi(string Made)
        {
            dt = GetKetnoi();
            IEnumerable<CAUHOI> q = from i in dt.CAUHOIs
                                    join j in dt.CHITIETDETHIs
                                    on i.MACAUHOI equals j.MACAUHOI
                                    where j.MADETHI == Made
                                    select i;
            List<CauHoiThi> ds = new List<CauHoiThi>();
            foreach (CAUHOI item in q)
            {
                CauHoiThi ch = new CauHoiThi();
                ch.MaCauHoi = item.MACAUHOI;
                ch.NoiDung = item.NOIDUNG;
                ch.HinhAnh = item.HINHANH;
                ch.Flag = 0;
                DapAnDAL da = new DapAnDAL();
                ch.SoDapAnDung = da.TongSoDapAnDung(ch.MaCauHoi);
                ds.Add(ch);
            }
            return ds;
        }
    }
}
